import { Group, Object3D } from "three";
import { IEditorHistoryOptions } from "../EditorHistory";
import EditorCommand, { EnumEditorCommandName, EnumEditorCommandType, IEditorCommandOutput } from "./EditorCommands";
export interface IEditorAddObjectCommandOptions extends IEditorHistoryOptions {
    object: Group,
}
export default class EditorAddObjectCommand extends EditorCommand {
    object: Group;
    constructor(options: IEditorAddObjectCommandOptions) {
        super(options);
        this.type = EnumEditorCommandType.AddObjectCommand;
        this.object = options.object;
        // this.name = EnumEditorCommandName.AddObject + ':' + options.object.uuid;
        this.name = EnumEditorCommandName.AddObject;

    }

    execute() {
        this.editor.sceneMoveObject3DList.push(this.object);
        this.editor.historyStore.addObject(this.object);
        this.editor.selectMeshGroupFunction(this.object);
    }

    undo() {
        this.editor.sceneMoveObject3DList = this.editor.sceneMoveObject3DList.filter(item => item.uuid !== this.object.uuid);
        this.editor.historyStore.removeObject(this.object);
        this.editor.deselectMeshGroupFunction();
    }

    update(params: this) {
        throw new Error("Method not implemented.");
    }

    // toJSON() {
    // const output = super.toJSON(this);
    // output.object = this.object.toJSON();
    // return output;
    // }

    // fromJSON(json) {
    // super.fromJSON(json);
    // this.object = this.editor.objectByUuid(json.object.object.uuid);
    // if (this.object === undefined) {
    //     const loader = new ObjectLoader();
    //     this.object = loader.parse(json.object);
    // }
    // }
}